package com.stone.design.mode.proxy.cglib;

import org.springframework.cglib.core.DebuggingClassWriter;
import org.springframework.cglib.proxy.Enhancer;

public class CglibProxyTest {

    public static void main(String[] args) throws SecurityException, IllegalArgumentException {
        // 生成class类的路径
        System.setProperty(DebuggingClassWriter.DEBUG_LOCATION_PROPERTY, "/Users/wenpanfeng/Desktop/常用文件/temp/cglib");

        // cglib代理需要使用Enhancer
        Enhancer enhancer = new Enhancer();
        enhancer.setSuperclass(Student.class);
        enhancer.setCallback(new CglibProxy());

        // 创建cglib代理对象
        Student student = (Student) enhancer.create();
        student.say();
    }
}